<?php
/**
* @version		$Id: view.html.php 23246 2010-04-01 07:34:40 ngo.bieu@mwc.vn $
* @package		Joomla
* @subpackage	Shop_categorys
* @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

jimport( 'joomla.application.component.view');
jimport('joomla.html.pane');

/**
 * HTML View class for the Shop_categorys component
 *
 * @static
 * @package		Joomla
 * @subpackage	Shop_categorys
 * @since 1.0
 */
class Mwc_serversViewMwc_server extends JView
{
	function display($tpl = null)
	{
		global $mainframe;

		if($this->getLayout() == 'form') {
			$this->_displayForm($tpl);
			return;
		}

		//get the shop_category
		$mwc_server =& $this->get('data');

		if ($mwc_server->url) {
			// redirects to url if matching id found
			$mainframe->redirect($mwc_server->url);
		}

		parent::display($tpl);
	}

	function _displayForm($tpl)
	{
		global $mainframe, $option;

		$db		=& JFactory::getDBO();
		$uri 	=& JFactory::getURI();
		$user 	=& JFactory::getUser();
		$model	=& $this->getModel();
		
		$editor =& JFactory::getEditor();
		
		//JHTML::stylesheet( 'shop_category.css', 'administrator/components/com_shop_category/assets/' );
		
		JHTML::_('behavior.calendar');
		JHTML::_('behavior.modal', 'a.modal-button');
		$button = new JObject();
		$button->set('modal', true);
		$button->set('modalname', 'modal-button');
		$button->set('options', "{handler: 'iframe', size: {x: 760, y: 520}}");

		$lists = array();

		//get the shop_category
		$mwc_server	=& $this->get('data');
		$isNew		= ($mwc_server->id < 1);

		// Edit or Create?
		if ($isNew) {
			// initialise new record
			$mwc_server->published = 1;
		}
		
		// build list of categories
//		$lists['category_id'] 			= JHTML::_('list.category',  'category_id', $option, intval( @$mwc_server->category_id ) );
		
		// helper
		require_once "components/com_mwc_server/helpers/mwc_server.php"; 
		require_once "components/com_mwc_category/helpers/mwc_category.php";
		
		$lists['category_id'] 			= Mwc_categoryHelper::dropdown($model->_prefix.'category_id', intval( @$mwc_server->category_id ), NULL, FALSE );
		
		//clean shop_category data
		//JFilterOutput::objectHTMLSafe( $mwc_server, ENT_QUOTES, 'price_1_month' );

		// build the html select list
		$lists['published'] 		= JHTML::_('select.booleanlist',  $model->_prefix.'published', 'class="inputbox"', $mwc_server->published );

		// build the html select list for ordering
		$query = 'SELECT ordering AS value, server_name AS text'
			. ' FROM #__a_servers'
			. ' ORDER BY ordering';
		$lists['ordering'] 			= JHTML::_('list.specificordering',  $mwc_server, $mwc_server->id, $query );

		$lists['created'] 		 	= JHTML::_('date', $mwc_server->created, '%Y-%m-%d %H:%M:%S');

//		$lists['modified'] 		 	= JHTML::_('date', $mwc_server->modified, '%Y-%m-%d %H:%M:%S');

		//clean shop_category data
		JFilterOutput::objectHTMLSafe( $mwc_server, ENT_QUOTES, 'params' );

		//clean shop_category data
//		JFilterOutput::objectHTMLSafe( $mwc_server, ENT_QUOTES, 'short_description' );

//		$lists['filename_src'] 		 	= JURI::root(false).$mwc_server->filename;
		$lists['thumbnail_src']		 	= JURI::root(false).$mwc_server->thumbnail;
		
		$lists['comdir'] = JURI::root(false).'administrator/components/com_mwc_server/assets/';
		
		$lists['gallerydir'] = JURI::root(false).'images/rokquickcart';
		
		$this->assignRef('lists', $lists);
		$this->assignRef('mwc_server', $mwc_server);
		$this->assignRef('button', $button);
		$this->assignRef('editor', $editor);
		$this->assignRef('prefix', $model->_prefix);
		$this->assign('action', $uri->toString());
		
		//$component_params = &JComponentHelper::getParams($option);
		$paramfile 	= JPath::clean(JPATH_COMPONENT.'/views/mwc_server/params.xml');
		$params = new JParameter(@$mwc_server->params, $paramfile);
		//$component_params->loadINI(@$mwc_server->params);
		//$params->set('<attr>', '<val>');
		$sliders = JPane::getInstance('sliders');
		$this->assignRef('pane', $sliders);
		$this->assignRef('params', $params);

		parent::display($tpl);
	}
}
